package com.example.paper.mvp.view.user.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.paper.R;
import com.example.paper.brean.UserIteamEntivy;

public class UserAdapter extends BaseQuickAdapter<UserIteamEntivy, BaseViewHolder> {

    public UserAdapter() {
        super(R.layout.item_user_itemes);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserIteamEntivy item) {
        helper.setText(R.id.user_itemes_tv,item.name);
        helper.setImageResource(R.id.user_items_arrow_img,R.drawable.icon_pn_arrows);

        ImageView user_items_arrow_img = helper.itemView.findViewById(R.id.user_items_arrow_img);
        user_items_arrow_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.selFlag = !item.selFlag;
                if (item.name.equals("夜间模式")){
                    if (item.selFlag){
                        helper.setImageResource(R.id.user_items_arrow_img,R.drawable.new_on);
                    }else {
                        helper.setImageResource(R.id.user_items_arrow_img,R.drawable.new_off);
                    }
                }
            }
        });

        if (item.name.equals("夜间模式")){
            if (item.selFlag){
                helper.setImageResource(R.id.user_items_arrow_img,R.drawable.new_on);
            }else {
                helper.setImageResource(R.id.user_items_arrow_img,R.drawable.new_off);
            }
        }
    }

}
